<div class="row-fluid">
    <div class="span12">

        <div class="mediamgr_head">
            <ul class="mediamgr_menu">
                <li class="marginleft5 trashbtn"><a class="btn trash" title="Trash">Color Coded Keys</a></li>
                <li class="marginleft15 filesearch">
                    <span class="label label-blue">Future Appointments</span>
                    <span class="label label-yellow">Appoints for Today waiting for customer</span>
                    <span class="label label-red">Overdue Appointment Customer Did not show up.</span>
                    <span class="label label-inverse">Appointment Met Customer showed Up.</span>
                </li>
            </ul>
            <span class="clearall"></span>
        </div><!--mediamgr_head-->

    </div>
</div>

<div class="row-fluid">
    <div class="span12">

        <div class="mediamgr_head">
            <?php echo $this->Form->create('FormFilter', array('id' => 'form-filter','class'=>'form-horizontal'));?>
            <ul class="mediamgr_menu">
                <li class="marginleft15 filesearch">
                    <?php echo $this->Form->input('customer', array('id' => 'customer', 'class' => '', 'options' => $customers_filter_list, 'div' => false, 'label' => false)); ?>
                </li>
                <li class="marginleft15 filesearch">
                    <?php echo $this->Form->input('vehicle_type', array('id' => 'vehicle_type', 'class' => '', 'options' => $vehicle_type_filter_list, 'div' => false, 'label' => false)); ?>
                </li>
                <!--<li class="marginleft5 trashbtn"><a class="btn trash" title="Trash">OR</a></li>-->
                <li class="marginleft15 filesearch">
                    <?php echo $this->Form->input('vehicle_number', array('id' => 'vehicle_number', 'class' => '','placeholder' => 'Vehicle Number', 'div' => false, 'label' => false)); ?>
                </li>
                <li class="marginleft5 trashbtn"><button id="filter_btn" type="button" class="btn trash" title="Trash">Filter</button></li>
            </ul>
            <?php echo $this->Form->end();?>
            <span class="clearall"></span>
        </div><!--mediamgr_head-->

    </div>
</div>

<div class="row-fluid">
    <!--span6-->
    <div id="dashboard-right" class="span6 profile-left">

        <div class="widgetbox tags">
            <h4 class="widgettitle">Today Reminders List</h4>
            <div class="widgetcontent">
                <ul class="taglist">
                    <?php
                    foreach($today_reminders['data'] as $k => $arr){
                        if($arr['reminded'] == 'Reminded'){
                    ?>
                            <li><a class="turned-up" href="javascript:void(0);"><?php echo '<strong>'.$arr['name'].'</strong> | '.$arr['telephone'].' | '.$arr['vehicle_type'].' | '.$arr['vehicle_number']; ?><span class="iconfa-bell"> x <?php echo $arr['reminder_count'];?></span>  </a></li>
                    <?php
                        }
                        else{
                    ?>
                            <li><a href="javascript:void(0);"><?php echo '<strong>'.$arr['name'].'</strong> | '.$arr['telephone'].' | '.$arr['vehicle_type'].' | '.$arr['vehicle_number']; ?> </a></li>
                    <?php
                        }
                    }
                    ?>
                </ul>
                <!--<a href="#" style="display:block;margin-top:10px">+ Add Tag</a>-->
            </div>
        </div>
    </div>

    <div id="dashboard-right" class="span6 profile-left">
        <div class="widgetbox tags box-warning">
            <h4 class="widgettitle">Today Appointments List</h4>
            <div class="widgetcontent">
                <ul class="taglist">
                    <?php
                    foreach($today_appointments['data'] as $k => $arr){
                        if($arr['serviced'] == 'Serviced'){
                    ?>
                            <li><a class="turned-up" href="javascript:void(0);"><?php echo '<strong>'.$arr['name'].'</strong> | '.$arr['telephone'].' | '.$arr['vehicle_type'].' | '.$arr['vehicle_number']; ?>&nbsp;<span class="icon-check icon-white"></span></a></li>
                    <?php
                        }
                        else{
                    ?>
                            <li><a href="javascript:void(0);"><?php echo '<strong>'.$arr['name'].'</strong> | '.$arr['telephone'].' | '.$arr['vehicle_type'].' | '.$arr['vehicle_number']; ?>&nbsp; <button class="btn btn-warning btn-small turned-up-btn" data-id=<?php echo $arr['id'];?> >Turned Up</button></a></li>
                    <?php
                        }
                    }
                    ?>
                </ul>
                <!--<a href="#" style="display:block;margin-top:10px">+ Add Tag</a>-->
            </div>
        </div>
    </div>


   <!-- <div id="dashboard-right" class="span4 profile-left">
        <div class="widgetbox tags box-danger">
            <h4 class="widgettitle">Overdue Appointments List</h4>
            <div class="widgetcontent">
                <ul class="taglist">
                    <?php
/*                    foreach($overdue_appointments as $k => $arr){
                        $smaller_date =  date('Y-m-d');
                        $bigger_date = $arr['next_service_date'];
                        $sd_dt = 'As of '.$this->App->convertDate($bigger_date,'ui');
                        */?>
                        <li><a href="javascript:void(0);"><?php /*echo '<strong>'.$arr['name'].'</strong> | '.$arr['telephone'].' | '.$arr['vehicle_type'].' | '.$arr['vehicle_number']; */?>&nbsp; </a></li>
                    <?php
/*                    }
                    */?>
                </ul>
            </div>
        </div>
    </div>-->
</div><!--row-fluid-->

<div id="appointment_modal" class="modal hide fade">
    <?php echo $this->Form->create('CustomerAppointment', array('id' => 'form-appointment','class'=>'form-horizontal'));?>
   <!-- <form class="form form-horizontal" method="post" action="" enctype="" style="margin: 0px;">-->
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4>Service Appointment</h4>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label" for="password">Customer:</label>
                <div class="controls">
                    <?php echo $this->Form->input('customer_id', array('id' => 'customer_id', 'class' => '', 'options' => $customers_list, 'div' => false, 'label' => false)); ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="password">Vehicle Number:</label>
                <div class="controls">
                    <?php echo $this->Form->input('vehicle_number', array('id' => 'vehicle_number', 'class' => 'input input-large', 'required'=>'' ,'div' => false, 'label' => false)); ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="password">Vehicle Type:</label>
                <div class="controls">
                    <?php echo $this->Form->input('vehicle_type', array('id' => 'vehicle_type', 'class' => '', 'options' => $vehicle_type_list, 'div' => false, 'label' => false)); ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="password">Next Service Date:</label>
                <div class="controls">
                    <?php echo $this->Form->input('next_service_date', array('type'=>'text','id' => 'next_service_date', 'class' => 'input input-large', 'readonly'=>'readonly','required'=>'','div' => false, 'label' => false)); ?>
                </div>
            </div>
            <!--<div class="control-group">
                <label class="control-label" for="password">Service End Date:</label>
                <div class="controls">
                    <?php /*echo $this->Form->input('end_date', array('type'=>'text','id' => 'end_date', 'placeholder'=>$end_date,'class' => 'input input-large','div' => false, 'label' => false)); */?>
                </div>
            </div>-->
            <div class="control-group">
                <label class="control-label" for="password">Reminder Time:</label>
                <div class="controls">
                    <?php echo $this->Form->input('reminder_time', array('id' => 'reminder_time', 'class' => '', 'options' => $reminder_time_list, 'div' => false, 'label' => false)); ?>
                </div>
            </div>
            <div class="control-group hide-me">
                <label class="control-label" for="repeat">Repeat:</label>
                <div class="controls">
                    <?php echo $this->Form->input('CustomerAppointmentParent.repeat', array('id' => 'repeat', 'class' => '', 'options' => array('No'=>'No','Yes'=>'Yes'), 'div' => false, 'label' => false)); ?>
                </div>
            </div>
            <div class="control-group hide-me">
                <label class="control-label" for="repeat">Repeat Frequency (Every):</label>
                <div class="controls">
                    <?php echo $this->Form->input('CustomerAppointmentParent.repeat_freq', array('id' => 'repeat_freq', 'class' => '', 'options' => $cal_repeat_freq, 'div' => false, 'label' => false)); ?>
                </div>
            </div>

            <?php echo $this->Form->input('id', array('type'=>'hidden','id' => 'id', 'value' => '0','class' => '')); ?>
            <?php echo $this->Form->input('edit_instances', array('type'=>'hidden','id' => 'edit_instances', 'value' => 'No','class' => '')); ?>
            <?php echo $this->Form->input('prev_repeat_val', array('type'=>'hidden','id' => 'prev_repeat_val', 'value' => '0','class' => '')); ?>
            <?php echo $this->Form->input('CustomerAppointmentParent.id', array('type'=>'hidden','id' => 'parent_id', 'value' => '0','class' => '')); ?>
        </div>
        <div class="modal-footer">
            <button type="submit" href="<?php echo $this->Html->url(array('action' => 'service_appointments/save')); ?>" id="appointment_btn" class="btn btn-primary">Save Service Appointment</button>
            <a href="#appointment_modal" class="btn" data-toggle="modal">Close</a>
        </div>
    <?php echo $this->Form->end();?>
</div>


<div class="row-fluid">
    <!--span12-->
    <div id="dashboard-left" class="span12">
        <div id='schedule_appointments'></div>

        <br/>

    </div>
</div><!--row-fluid-->

<input type="hidden" id="delete_appointment_url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'service_appointments/delete')); ?>" />
<input type="hidden" id="update_appointment_url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'service_appointments/update')); ?>" />
<input type="hidden" id="turned_up_appointment_url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'service_appointments/turned_up')); ?>" />
<input type="hidden" id="get_appointment_url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'service_appointments/get_appointments')); ?>" />


<script type="text/javascript">
    //var event_data = <?php //echo json_encode($appointments); ?>;
    var reminder_time_list = <?php echo json_encode($reminder_time_list); ?>;
</script>

<?php
    echo $this->Html->script('scripts/service_advisers/service_appointments.js');
?>